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
1
vote
0 answers

How do I use the value of the previous year-week as the comparison in a negative binomial regression in R?

I have a dataset that contains weekly counts from 2019 to 2021. What I want to do is to compare the weekly count for a given week in 2020 to the count for the same week in 2019, and similarly compare the count in 2021 to that of the same week in…
VLarsen
  • 67
  • 1
  • 7
1
vote
1 answer

Remove grid from parcoord() function (library MASS)

I'm trying to plot a parallel coordinate plot with a dataset that has 1270 dimensions/variables, and the plot appears to be all a grey area because of the background grid (if I plot the same dataset with 800 dimensions I still get the grid occupying…
Sara Bossa
  • 13
  • 2
1
vote
1 answer

Where should I put the time-invariant variables in a glmm.PQL function to perform a time-dependent negative binomial regression?

Recently I have processed and cleaned a data for the aim of application of a negative binomial regression. First, I tried to use the function glm.nb of package MASS in R and I had a problem with ensuring that the model will realize the data are for…
Amir
  • 21
  • 6
1
vote
1 answer

Complex function that iterates mvrnorm over rows of a data frame

I have data that looks like this: data = data.frame(a.coef = c(.14, .15, .16), b.coef = c(.4, .5, .6), a.var = c(0.0937, 0.0934, 0.0945), b.var = c(0.00453, 0.00564, 0.00624), …
Addison
  • 143
  • 7
1
vote
1 answer

Specify theta.ml parameters within glmer.nb

I am trying to fit a mixed-effect negative binomial model with glmer.nb() from package lme4. m1 <- glmer.nb(NumberEvents ~ offset(log(days)) + x + (1|ID), data=dfr, nAGQ = 20) I get the following warning: Warning message: In theta.ml(Y, mu,…
Pierpaolo
  • 11
  • 2
1
vote
0 answers

Comparison between the estimated versus observed Poisson and Binomial distributions does not produce adequate results

# Packages library(MASS)# Pacote MASS library(car) # Pacote car # Create some artificial numbers with binomial negative distribution S<-10 P<-0.6 N<-rnbinom(n=283, size=S, prob=P) # Poisson…
Leprechault
  • 1,531
  • 12
  • 28
1
vote
1 answer

'MASS::predict.lda' is not an exported object from 'namespace:MASS'

This R code: Iris <- data.frame(rbind(iris3[,,1], iris3[,,2], iris3[,,3]), Sp = rep(c("s","c","v"), rep(50,3))) train <- sample(1:150, 75) z <- MASS::lda(Sp ~ ., Iris, prior = c(1,1,1)/3, subset =…
janonime
  • 125
  • 5
1
vote
1 answer

Error in svd(X) : infinite or missing values in 'x'

I'm trying to run ordered logit regression using the mass package and I keep coming up with this error message in R. I'm running the model fit2 <- polr(level ~ pvi + enrollment, data = schools, Hess = TRUE) summary(fit2) But this gives me the error…
1
vote
0 answers

R: regression output reports different results every time run

I have encountered a problem in R that seems fairly odd to me to say the least. I fitted a robust regression framework using rlm from the MASS package so the specification is like this: regression <- rlm(y ~ x1 + x2 + log(x3) , data…
1
vote
1 answer

Why do MASS:lm.ridge coefficents differ from those calculated manually?

When performing ridge regression manually, as it is defined solve(t(X) %*% X + lbd*I) %*%t(X) %*% y I get different results from those calculated by MASS::lm.ridge. Why? For ordinary linear regression the manual method (computing the pseudoinverse)…
Igor F.
  • 2,649
  • 2
  • 31
  • 39
1
vote
1 answer

Create %-contour in a 3d kernel density and find which points are within that contour

I want to plot the isosurface of a specific %-contour in a 3d kernel density estimate. Then, I want to know which points are within that 3d shape. I'll show I approach the 2d situation to illustrate my problem (code imitated from R - How to find…
1
vote
2 answers

Why is R treating this data.frame object as a list?

I am trying to run a least discriminant analysis (lda()) on a data.frame I created by dividing several variables by an additional scaling variable (not shown here) in R using the MASS package. Below is a sample dataset and a sample version of the…
user2352714
  • 314
  • 1
  • 15
1
vote
0 answers

Clustered Standard Errors on POLR ordered logit with vcovCL gives "non-conformable arguments" error

I'm trying to get clustered standard errors on an ordered logit regression using the POLR function from MASS. The regression has about 2,900 fixed effects, (U.S. counties and years.) When I run the regression without the fixed effects, I'm able to…
ModalBro
  • 544
  • 5
  • 25
1
vote
1 answer

Discrepancy in Results from epiDisplay ordinal.or.display p value and calculated p for polr from MASS package?

I am trying to calculate Odds Ratios and associated p-values for a set of biomarkers using ordinal logistic regression (specifically, polr from MASS package). I've been using the 'ordinal.or.display()' function from the epiDisplay package to view…
svanalsten
  • 11
  • 1
1
vote
1 answer

Can I assign colors to MASS::parcoord() based on a logical condition?

Here's the code to generate a parallel coordinate plot: require(MASS) shoes <- data.frame(shoes) parcoord(shoes) The shoes data set is used to show the power of a paired t-test, which is just background info. There are two columns in shoes, A and…