Tom
Tom

Reputation: 115

stargazer() for models with singularities

I try to create a table of regression results using the stargazer package. Unfortunately stargazerrefuses to create the table because of singularities. As these singularities come from overlapping factors with many levels they are not easily avoided. That´s why I am looking for an alternative solution
Here's a working example adapted from a related thread :

library(sandwich)
library(stargazer)
set.seed(101)
dat<-data.frame(one=c(sample(1000:1239)),
            two=c(sample(200:439)),
            three=c(sample(600:839)),
            Jan=c(rep(1,20),rep(0,220)),
            Feb=c(rep(0,20),rep(1,20),rep(0,200)),
            Mar=c(rep(0,40),rep(1,20),rep(0,180)),
            Apr=c(rep(0,60),rep(1,20),rep(0,160)),
            May=c(rep(0,80),rep(1,20),rep(0,140)),
            Jun=c(rep(0,100),rep(1,20),rep(0,120)),
            Jul=c(rep(0,120),rep(1,20),rep(0,100)),
            Aug=c(rep(0,140),rep(1,20),rep(0,80)),
            Sep=c(rep(0,160),rep(1,20),rep(0,60)),
            Oct=c(rep(0,180),rep(1,20),rep(0,40)),
            Nov=c(rep(0,200),rep(1,20),rep(0,20)),
            Dec=c(rep(0,220),rep(1,20))) 
model <- lm(one ~ two + three + Jan + Feb + Mar + Apr + May + Jun + Jul + Aug + Sep + Oct + Nov +    Dec, data=dat)
summary(model)
stargazer(model)

Because of singularites I get the Error: subscript out of bounds. Do you have any ideas how to solve this problem?

Upvotes: 1

Views: 267

Answers (1)

user1953965
user1953965

Reputation:

This problem has been fixed. The more recent versions of stargazer (from 3.0) should have no problem with your example.

Upvotes: 1

Related Questions