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
4
votes
0 answers

Changing stepAIC to accommodate tweedie distributions

So I am trying to do a stepwise regression for a tweedie distribution. However, AIC is returned as NA by glm() if the family is tweedie, and this breaks the stepAIC command. I tried editting the code of the command to change extractAIC to…
J. Gursky
  • 121
  • 1
  • 9
4
votes
1 answer

add ticks to parcoord (parallel coordinates plot)

The parcoord function from the MASS package looks quite ok, but how can I add ticks to the four y-axis? Code is here: ir <- rbind(iris3[,,1], iris3[,,2], iris3[,,3]) parcoord(log(ir)[, c(3, 4, 2, 1)], col = 1 + (0:149)%/%50)
qed
  • 22,298
  • 21
  • 125
  • 196
3
votes
0 answers

Restrict variables and interaction selection in MASS::stepAIC

On my dummy model below I use the stepAIC in forward direction to select my predictives variables or interactions. Is there a way to make sure we cannot select both a variable and one of its interaction or the other way around ? For example : If…
qfazille
  • 1,643
  • 13
  • 27
3
votes
2 answers

Function not defined when calling aictab

I'm getting an error message when trying to generate an aictab table CODE library(MASS) library(AICcmodavg) set.seed(456) d <- data.frame(ID = 1:20, Ct = c(sample(x = 1:50, size = 12, replace = T), rep(x = 0, length.out = 8)), …
Darius
  • 489
  • 2
  • 6
  • 22
2
votes
1 answer

Customize ggpairs output and avoid the 'wrap' the function to supply argument

I'm using the crab data set from MASS library in R Studio. I want to create a scatterplot matrix of the five quantitative variables and an interaction variable of sp.sex as the only categorical variable using ggpairs. I have reordered the factor…
data_life
  • 387
  • 1
  • 11
2
votes
1 answer

Negative binomial glm.nb : Different results with unbalanced variable and complete separation

I am fitting a negative binomial model using glm.nb from the MASS package of R with as output Y depending on variable y1, x, and z . The problem is that I get different estimated coefficients using the same model but with the following equivalent…
Ph.D.Student
  • 704
  • 6
  • 27
2
votes
0 answers

Simulating highly correlated data for 25 variables via multivariate normal distribution

I try to simulate highly correlated (average absolute correlation of ~0.7) variables for 25 variables using 4,000 observations. However, I can't get Sigma positive definite, and thus I need to use a trick to get sigma PD. And hereby I lose most of…
2
votes
1 answer

Nonparametric tolerance interval with MASS package

In R, using the 'geyser' dataset from the MASS library, we are building a nonparametric tolerance interval cont. 90% of geyser eruptions w/ 99% CI Please, find below the equation I am using: no_param_pi <- function(x, conf.level = 0.90) { n <-…
2
votes
1 answer

How to use ordinal regression (svyolr) with raked data?

Analyzing ordinal data with the survey package, I encountered some issues when trying to use raked data. Without raking, svyolr() works without any problem, but when I try to analyze after raking, svyolr encounters an error Error in if (any(y < 0 |…
Mathdragon
  • 92
  • 11
2
votes
0 answers

I can't get confidence intervals for ordered logistic function in R with one predictor/covariate variable?

I am using the polr fucntion in R for ordered logistic regression with one covariate/predictor variable. Here is my formula below: library(MASS) telangiec_ordinal <- polr(telangiectasia_tumour_24_adj ~ prs, data = PRS_covar_ordinal_wo_na, method =…
HKJ3
  • 387
  • 1
  • 10
2
votes
1 answer

simulate negative binomial distribution with offset variable

I am trying to simulate mutation data with known parameters to use it further for testing regression functions. In this simulation I want mutation counts to be dependent on variables: mutations ~ intercept + beta_cancer + beta_gene + beta_int +…
lizaveta
  • 353
  • 1
  • 13
2
votes
2 answers

Getting confidence intervals for robust regression coefficient (MASS::rlm)

Is there any possible way to get 95% CI for regression coefficients from the robust regression, as implemented in MASS::rlm? # libraries needed library(MASS) library(stats) library(datasets) # running robust regression (x <- MASS::rlm(formula =…
Indrajeet Patil
  • 4,673
  • 2
  • 20
  • 51
1
vote
0 answers

Why do I get these errors when running a negative binomial GLM?

Initially, I tried running a poisson GLM on count data (no of eggs laid) with four independent variables (Temperature - factor with 4 levels; Sex.treated - factor with two levels; Species - factor with two levels; Date.mated - factor with 9…
1
vote
1 answer

MASS::rlm method with na.action = na.exclude does not work

I have a question regarding the function rlm of the MASS package. The function fits a linear model by robust regression and has the argument na.action. The user should have the option to specify the action to be taken if NAs are found. I explicitly…
Arend Lis
  • 23
  • 5
1
vote
2 answers

R MASS::lda using cov.mve method - reproducability issues

I am trying to model some data, using LDA, which is multivariate non-normal. I was hoping to get a more robust estimation, by choosing method = 'mve'. However this leads to variable predictions - minimal example…
1
2 3 4 5