Questions tagged [mass]

MASS is an R package used in support of "Modern Applied Statistics with S" (Venables and Ripley). Use with the [r] tag.

70 questions
0
votes
1 answer

How to resolve Inf. $y values when using MASS::boxcox?

I am getting Inf. output for $y when running a box cox transformation using the MASS package. Here is a sample of the code I am running: sb2<- as.formula("yes~no+insured+sex2+racethx+mnhlth53+rthlth53+age13x") meps_analytic2 %>% …
smitt173
  • 3
  • 2
0
votes
0 answers

Add offset() in as.formula(paste0(...))

I need to add an offset(of variable) in an as.formula(paste0(...)) in R's glm.nb function, but I get errors using update() or unliste(offset()). Is there a way to do it? Here is my attempt: z <- c("T3", "T3", "T3", "T2", "T2", "T3", "T3", "T2",…
Ph.D.Student
  • 704
  • 6
  • 27
0
votes
0 answers

Posterior probabilities of belonging to class k in MASS::lda() are different from the ones i am computing. Why?

I want to compute the posterior probabilities within the linear discriminant analysis framework, to choose a class with maximum posterior probability given X. I got the results provided by the function MASS::lda(). Now i want to compute these…
maluicr
  • 37
  • 6
0
votes
0 answers

Is it possible in R to comput LDA using the predictor index?

I want to use LDA only with each predictor separately. Therefore I want to use a for loop and for that I need to perform LDA without using the name of the predictor and using its index instead. When I use the name of the predictor (for example,…
IreneGS
  • 1
  • 1
0
votes
0 answers

Car Package in R: powerTransform() - Error non-finite finite-difference value [1]

Issue: I have a data frame (called Yeo) containing six parameters with continuous values (columns 5-11)(see parameters below) and I conducted a Shapiro-Wilk test to determine whether or not the univariate samples came from a normal distribution.…
Alice Hobbs
  • 1,021
  • 1
  • 15
  • 31
0
votes
0 answers

Perform Within transformation manually in R

I was recently working with the rlm function from the MASS package, seeking to fit a robust regression for a panel. Just like many other functions, rlm does not have a built-in way to introduce fixed effects. ID dummies however cost too much degrees…
0
votes
2 answers

Negative Binomial model offset seems to be creating a 2 level factor

I am trying to fit some data to a negative binomial model and run a pairwise comparison using emmeans. The data has two different sample sizes, 15 and 20 (num_sample in the example below). I have set up two data frames: good.data which produces the…
Max F
  • 21
  • 5
0
votes
0 answers

Ordered Logit with Fixed Effects in R

I am trying to implement fixed effects to ordered logit. I know there is a polr function of the MASS package but I have not found the way to implement fixed effects to polr function. I will use country and year as fixed effects. (I have almost 50…
Yusuf
  • 29
  • 4
0
votes
1 answer

glm.nb non-convergence and other options for negative binomial regression

I'm trying to implement a glm with a negative binomial distribution in R and have a few questions. Here are the data I'm working with - note that my predictors are all centred and scaled using 2 standard deviations. df <- structure(list(offset_var =…
Conrad
  • 45
  • 6
0
votes
0 answers

Step vs. StepAIC

I'm trying to understand why my code has taken several days to process and how I can improve the next iteration. I'm on my third day and continue to have outputs with marginal improvements in AIC. The last couple of AIC's have been 18135.38,…
thou
  • 35
  • 4
0
votes
0 answers

mvrnorm() in MASS package is not working when making some calculations in arguments

A strange behavior of the mvrnorm() function occured to me as I tried to make some calculation in one of the arguments. This does do the job: mvrnorm( n=200, mu = c('x'=0,'y'=0), Sigma = matrix(c(1,0.5,0.5,1),nrow = 2), empirical =…
Rtist
  • 3,825
  • 2
  • 31
  • 40
0
votes
0 answers

Modeling by "lda" in R

I'm trying to train my data of gene expression based on cancer Recurrence(R) or Non-Recurrence(NR). My dataset that I'm working on : dim(all_C) [1] 87 11 87 samples and 10 Genes(a column is called "Condition", which shows that each sample is R or…
0
votes
1 answer

Negative Binomial Model in R: glmer.nb

Running this glmer.nb, I received the error message boundary (singular) fit: see ?isSingular Warning message: In theta.ml(Y, mu, weights = object@resp$weights, limit = limit, : iteration limit reached I ran singular(model) and it return TRUE.…
karyn-h
  • 133
  • 7
0
votes
1 answer

using weights in a glmmPQL

Using the 'baltimore' housing data from SpData, I want to model the presence of a patio as the response variable, with house price as the explanatory variable. I also want to include weights in my model by housing area. My…
0
votes
1 answer

lda from MASS-package with more predictors than observations

I am fairly new to multivariat statistics and cannot find the answer in the help-Section of R neither in the source of the MASS-package so maybe you can help me. My data has many predictors (450) and just few observations (~200). I read it is not…
bienexo
  • 35
  • 6