note:
https://github.com/agrogan1/multilevel-thinking/raw/main/simulate-and-a
> nalyze-multilevel-data/simulated_multilevel_data.dta redirected to
https://raw.githubusercontent.com/agrogan1/multilevel-thinking/main/sim
> ulate-and-analyze-multilevel-data/simulated_multilevel_data.dta
Contains data from https://github.com/agrogan1/multilevel-thinking/raw/main/sim
> ulate-and-analyze-multilevel-data/simulated_multilevel_data.dta
Observations: 3,000
Variables: 8 21 Apr 2023 12:38
-------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
-------------------------------------------------------------------------------
country float %9.0g country id
HDI float %9.0g Human Development Index
family float %9.0g family id
id str7 %9s unique country family id
group float %9.0g arbitrary group variable
physical_puni~t float %9.0g physical punishment in past week
warmth float %9.0g parental warmth in past week
outcome float %9.0g beneficial outcome
-------------------------------------------------------------------------------
Sorted by: country family
3 Setup
We need to create a categorical outcome variable for demonstration purposes.
* create an outcome_group variableegen outcome_group = cut(outcome), group(3) // divide outcome into groupslabeldefine outcome_group 0 "low" 1 "medium" 2 "high"// define value labelslabelvalues outcome_group outcome_group // attach value labelstabulate outcome_group
Running C:\Users\agrogan\Desktop\GitHub\newstuff\categorical\ordinal-multinomia
> l-logistic-regression-2\profile.do .
outcome_gro |
up | Freq. Percent Cum.
------------+-----------------------------------
low | 1,000 33.33 33.33
medium | 1,000 33.33 66.67
high | 1,000 33.33 100.00
------------+-----------------------------------
Total | 3,000 100.00
Because the data are clustered by countries, we will use the , cluster(country) option in each model. The brant command can be installed by typing findit brant, and installing the Long & Freese spost utilities.
ologit outcome_group physical_punishment warmth HDI i.group, orcluster(country) // ordinal logitbrant // brant testmargins, at(warmth = (1(1)7)) // margins at different values of warmthmarginsplot, title("Predicted Probabilities From Ordinal Logit") /// plot(_outcome, labels("low""medium""high")) // graph w/ manual labelsgraphexport myologit.png, replace
Because the Brant test was insignificant, the results below are likely to look similar. Imagine, however, if the Brant test were statistically significant, suggesting that we should estimate separate regression coefficients for each value of the outcome. Imagine, in addition, if we were estimating an outcome that were truly multinomial in nature, such as post-secondary education pursued: none, vocational, university. For heuristic purposes, we will relabel the outcome accordingly.
labeldefine outcome_group2 0 "none" 1 "vocational" 2 "university"// define value labelslabelvalues outcome_group outcome_group2 // attach NEW value labelstabulate outcome_groupmlogit outcome_group physical_punishment warmth HDI i.group, rr cluster(country)margins, at(warmth = (1(1)7)) // margins at different values of warmthmarginsplot, title("Predicted Probabilities From Multinomial Logit") ///plot(_outcome, labels("none""vocational""university")) // graph w/ manual labelsgraphexport mymlogit.png, replace