Use this tag for question about the MASS Package for the programming language R
Questions tagged [mass-package]
11 questions
6
votes
3 answers
R Passing linear model to another function inside a function
I am trying to find the optimal "lambda" parameter for the Box-Cox transformation.
I am using the implementation from the MASS package, so I only need to create the model and extract the lambda.
Here is the code for the…

R-seny
- 63
- 2
3
votes
1 answer
R: Find cutoffpoint for continous variable to assign observations to two groups
I have the following data
Species <- c(rep('A', 47), rep('B', 23))
Value<- c(3.8711, 3.6961, 3.9984, 3.8641, 4.0863, 4.0531, 3.9164, 3.8420, 3.7023, 3.9764, 4.0504, 4.2305,
4.1365, 4.1230, 3.9840, 3.9297, 3.9945, 4.0057, 4.2313, 3.7135,…

OCSee
- 35
- 8
1
vote
1 answer
Fit negative binomial to zero-truncated (positive only) data
I just learned that MASS::fitdistr, when fitting a negative binomial, is sensitive to the number of zeroes... a bummer since I was hoping to fit this distribution to count data of species where the number of zeroes is unknown and I'd argue…

Michael Roswell
- 1,300
- 12
- 31
1
vote
2 answers
How to extract AIC from polr summary output in R
I'd like to quickly compare AICs that are provided as output when running summary() on individual polr() models created using the MASS package in R. I have no problem compiling this info, but what I can't figure out is where exactly the AIC info is…

theforestecologist
- 4,667
- 5
- 54
- 91
1
vote
1 answer
Box-Cox Tranformation Error: object 'x' not found
hopefully a relatively easy one for those more experienced than me!
Trying to perform a Box-Cox transformation using the following code:
fit <- lm(ABOVEGROUND_BIO ~ TREATMENT * P_LEVEL, data = MYCORRHIZAL_VARIANCE)
bc <-…

Sam Blackburn
- 13
- 2
1
vote
1 answer
lm.ridge() in R MASS package saying "Error in svd(X) : infinite or missing values in 'x'"
I'm trying to run a ridge regression on a dataset of 8*8 pixel coordinates. The dataset is a map of a series of 1s and 0s written by different hands, sorted as rows of 64 numerical values corresponding to the 8*8 pixel matrix.
The lm.ridge()…

Mohammad Ansarin
- 81
- 1
- 13
1
vote
0 answers
plotting hurdle regression output
I am attempting to plot hurdle regression output with an interaction term in r, but am having some trouble doing so with the count portion of the model.
Model <- hurdle(Suicide. ~ Age + gender + bullying*support, dist = "negbin", link =…

Nick
- 11
- 2
1
vote
0 answers
How to debug "invalid subscript type 'list'" error in R (genalg package)
I am new to genetic algorithms and am trying a simple variable selection code based on the example on genalg package's documentation:
data(iris)
library(MASS)
X <- cbind(scale(iris[,1:4]), matrix(rnorm(36*150), 150, 36))
Y <- iris[,5]
iris.evaluate…

user3416268
- 83
- 5
0
votes
1 answer
Passing a list as a parameter for the direction argument of the stepAIC function in the MASS package
I'd like to build three logistic regression models based on different methods for variable selection: a model with backward selection, a model with forward selection, and a model with stepwise selection.
I'm using base R glm() for setting up the…

Robbie
- 275
- 4
- 20
0
votes
0 answers
R: Generate normally-distributed spatial coordinates around point-of-interest
I have geographic (i.e. un-projected) spatial coordinates and would like to generate an n number of random coordinates around each original coordinate pair, such that the generated points follow a bi-variate normal distribution. The mean of the…

bealhammar
- 155
- 1
- 7
0
votes
0 answers
polr predicted values clustered in single class for MASS package
I am using the MASS package in R. I run ordered logit using polr on values below. However, all the predicted values are clustered in class 6. Am I doing something wrong?
x = rbind(
cbind(rep(1,1), runif(1,8.81,8.81)),
cbind(rep(2,63),…

earthlink
- 323
- 5
- 15