I am trying to run a multinomial logistic regression with the function mlogit
from the package of the same name. I would like to ignore NA values whose presence is always dependent on the value of other predictor (i. e. their presence is not meaningful, as it's a consequence of the structure of the data frame).
Suppose that I want to model the relationship between academic level, the device used for reading, the website from which books were downloaded and several other values. My data frame would look like this:
> ReadingChoice <- read.table("C:\\Users\\34648\\Documents\\ReadingChoice.txt", sep="\t", header=TRUE)
> head(ReadingChoice)
Device TimeforReading AcademicLevel DownloadedFrom
1 Ebook Night High Amazon
2 Ebook Morning High Genesis
3 Book Night Medium <NA>
4 Computer Noon Low Genesis
5 Book Morning Low <NA>
NAs in the predictor DownloadedFrom always depend on the predictor Device. When I run the function, I obtain this:
> ReadingChoice <- mlogit.data(ReadingChoice, shape="wide", choice="TimeforReading")
> LogisticRegression <- mlogit(TimeforReading ~ 1 | Device + AcademicLevel + DownloadedFrom, data=MadridR, reflevel=1)
Error in solve.default(H, g[!fixed]) :
Lapack routine dgesv: system is exactly singular: U[7,7] = 0
How should I run the mlogit
function? The aim is to make the algorithm skip those values but keeping the rows containing them. The arguments na.action
or na.omit
do not improve things. A similar question was posted about a year ago, but the one here is slightly different.
Thank you in advance!