# Multinomial regression interpretation

Hi all,

I have a multinomial regression comparing boys and girls on a 4 point Likert response to the question “I do well in reading” (this is for a course example). Typically, in multinomial regression , the coefficient gives me the difference between boys and girls on the comparison between, say the first response and the last response. Here I am getting all of the regression coefficients, and I am not sure what they mean.

Also does anyone out there know how to code up posterior predictive checks for multinomial regression such as the code I have above? Thanks!

Thanks. David

``````       mean se_mean   sd  2.5%   25%   50%  75% 97.5% n_eff
``````

beta[1,1] 0.41 0.17 2.34 -4.32 -0.98 0.49 1.91 4.87 180
beta[1,2] 0.27 0.17 2.35 -4.38 -1.07 0.31 1.76 4.91 181
beta[1,3] -0.07 0.17 2.34 -4.67 -1.46 -0.03 1.44 4.47 181
beta[1,4] -0.05 0.17 2.33 -4.67 -1.38 -0.05 1.50 4.51 183
beta[2,1] 0.46 0.24 2.52 -4.56 -1.11 0.66 2.20 5.27 107
beta[2,2] -0.06 0.24 2.52 -5.19 -1.73 0.19 1.74 4.82 107
beta[2,3] -0.32 0.24 2.50 -5.39 -1.95 -0.09 1.34 4.36 106
beta[2,4] -0.24 0.24 2.54 -5.28 -1.78 -0.01 1.55 4.68 109
Rhat
beta[1,1] 0.99
beta[1,2] 0.99
beta[1,3] 0.99
beta[1,4] 0.99
beta[2,1] 1.00
beta[2,2] 1.00
beta[2,3] 1.00
beta[2,4] 1.00

1 Like

Hi David, we’ll need a bit more information here. What Stan or brms syntax are you using to specify the regression?

1 Like

Of course. Here you go.

``````## Read in data ##
male:  (1=male)

ASBG04: # of books in home 1) 0-10, 2) 11-25, 3) 26-100, 4) 101-200 5) More than 200

ASBGSMR:  Students motivated to read (4pt, strongly agree to strongly disagree)

ASBR07A:  I do well in reading

```{r, echo=TRUE}
Canadareg <-read.csv("~/desktop/Canada.csv",header=TRUE) #browse to select data "Canada.csv"
Canadareg <- Canadareg[1:5000,]  # Just to cut down the sample size.
Canadareg[Canadareg==999999]=NA
Canadareg <- na.omit(Canadareg)
male <- ifelse(Canadareg\$ITSEX==2,0,1)
Canadareg1 <- subset(Canadareg,select=c(ASBR07A, male, ASBG04,ASBGSMR))
Canadareg1 < data.frame(Canadareg1)

attach(Canadareg1)
N <- nrow(Canadareg1)
f <- as.formula("ASBR07A ~ male")
M <- model.matrix(f,Canadareg1)

data.list <- list(N=nrow(M),
K=length(unique(Canadareg1[,1])),
D=ncol(M),
x=M,
ASBR07A=as.numeric(Canadareg1[,1]))

``````
``````modelString <- "

data {
int K;              // This is 4, the number of outcomes categories
int N;
int D;              // This is the number of columns in the design matrix - 2
int ASBR07A[N];
matrix[N, D] x;    // This will be N by 2 matrix of data
}

parameters {
matrix[D, K] beta;     // This is a 2 x 4 matrix of betas
}

model {
matrix[N, K] x_beta = x * beta;   //  N x 2  * 2  x 4

to_vector(beta) ~ normal(0, 5);

for (i in 1:N)
ASBR07A[i] ~ categorical_logit(x_beta[i]');
}
}
"
``````
1 Like

Great, thanks. Bob talked about the difference between the K and K-1 parameterisations in this stackoverflow post: https://stackoverflow.com/a/60588946

And the manual section he referred to is here: https://mc-stan.org/docs/2_24/stan-users-guide/multi-logit-section.html#identifiability

1 Like

Thanks. But without the K-1 specification are these parameters interpretable? Also, here is the Stan code with the K-1 specification as I understood it from the manual.

modelString <- "

data {
int K; // This is 4, the number of outcomes categories
int N;
int D; // This is the number of columns in the design matrix - 2
int ASBR07A[N];
matrix[N, D] x; // This will be N by 2 matrix of data
}

transformed data {
row_vector[D] zeros = rep_row_vector(0, D);
}

parameters {
matrix[K-1, D] beta_row; // This is a 2 x 4 matrix of betas
}

transformed parameters {
matrix[K, D] beta;
beta = append_row(beta_row, zeros);
}

model {
matrix[N, K] x_beta = x * beta; // N x 2 * 2 x 4

to_vector(beta) ~ normal(0, 5);

for (i in 1:N)
ASBR07A[i] ~ categorical_logit(x_beta[i]’);
}
}
"

The error message I am getting is

DIAGNOSTIC(S) FROM PARSER:
Info:
Left-hand side of sampling statement (~) may contain a non-linear transform of a parameter or local variable.
If it does, you need to include a target += statement with the log absolute determinant of the Jacobian of the transform.
Left-hand-side of sampling statement:
to_vector(beta) ~ normal(…)

PARSER FAILED TO PARSE INPUT COMPLETELY
STOPPED AT LINE 32:
}

Info:
Left-hand side of sampling statement (~) may contain a non-linear transform of a parameter or local variable.
If it does, you need to include a target += statement with the log absolute determinant of the Jacobian of the transform.
Left-hand-side of sampling statement:
to_vector(beta) ~ normal(…)

Error in stanc(file = file, model_code = model_code, model_name = model_name, :
failed to parse Stan model ‘9c728d9cd657025c917d354127f06a32’ due to the above error.

1 Like