Random Slope Model Country Prediction Lines for the Slope

Welcome to the forum for runmlwin users. Feel free to post your question about runmlwin here. The Centre for Multilevel Modelling take no responsibility for the accuracy of these posts, we are unable to monitor them closely. Do go ahead and post your question and thank you in advance if you find the time to post any answers!

Go to runmlwin: Running MLwiN from within Stata >> http://www.bristol.ac.uk/cmm/software/runmlwin/
Post Reply
KazimovHH
Posts: 14
Joined: Mon Apr 09, 2018 11:56 am

Random Slope Model Country Prediction Lines for the Slope

Post by KazimovHH » Thu Sep 27, 2018 11:01 am

Dear Users,

I am using runmlwin within Stata(15.1) in macOS (High Sierra).
Referring to Lemma 7.5, I am trying to plot the country prediction lines for the random slope (in my case Internal Efficacy). However, I cannot see explicit 'fanning in' given the covariance is negative. Any help would be greatly appreciated.

Here is my code:

Code: Select all

set seed 123
	sort cntry_n ind
	quietly runmlwin vote cons female_c uemp_c yhh_c eisced_c rlgdgr_c lrscale_c polintr_c ///
	Inteff_c Exteff_c ///
	dependency_c neet_c vtolder, ///
		level2(cntry_n: cons Inteff_c) level1(ind:) ///
		discrete(distribution(binomial) link(logit) denom(cons) pql2)
		
	runmlwin vote cons female_c uemp_c yhh_c eisced_c rlgdgr_c lrscale_c polintr_c ///
	Inteff_c Exteff_c ///
	dependency_c neet_c vtolder, ///
		level2(cntry_n: cons Inteff_c, residuals(u) level1(ind:) ///
		discrete(distribution(binomial) link(logit) denom(cons)) ///
		mcmc(orthogonal) or initsprevious nopause nogroup
Results:
temp.rtf
(4.85 KiB) Downloaded 110 times

After running the model, I change the values of variables to zero only adjusted for education and political interest as follows:

Code: Select all

sum female_c 
		replace female_c = 0
	sum uemp_c
		replace uemp_c = 0
	sum yhh_c
		replace yhh_c = 0
	sum eisced_c
		replace  eisced_c = r(mean)
	sum rlgdgr_c
		replace rlgdgr_c = 0
	sum lrscale_c
		replace lrscale_c = 0
	sum polintr_c
		replace polintr_c = r(mean)
	sum Exteff_c 
		replace Exteff_c = 0
	bysort cntry_n:sum dependency_c 
		replace dependency_c = 0
	bysort cntry_n:sum neet_c
		replace neet_c = 0
	bysort cntry_n: sum vtolder
		replace vtolder = 0
Then calculating predlogit as follows:

Code: Select all

* Calculate the predicted probability for each young voter in the data based only on the fixed part of the model adjust education and political interest.		
	predict predxb
	generate predprob = invlogit(predxb)
* Transform these predicted probabilities back to predicted log-odds:
	generate predlogit = logit(predprob)
	replace predlogit = predlogit + u0 + u1*Inteff_c
* Sort the observation for each country based on the Internal efficacy score 	
	egen pickone = tag(cntry_n Inteff_c)
	generate multiple = pickone
	bysort cntry_n (Inteff_c): replace multiple = 0 if Inteff_c[_N]==Inteff_c[1]
* Plot
	line predlogit Inteff_c if multiple==1, ///
	connect(ascending) xtitle(Internal Efficacy) ytitle(Predicted Value) 
Finally, I got the following graph which is not clear whether the pattern is 'fanning in'.
randomslopetest.png
randomslopetest.png (140.98 KiB) Viewed 1600 times
Looking forward,
Regards,
Rza

PS: I was not able to attach 'dta' Stata data file. Status says 'The upload was rejected because the uploaded file was identified as a possible attack vector.'

GeorgeLeckie
Site Admin
Posts: 424
Joined: Fri Apr 01, 2011 2:14 pm

Re: Random Slope Model Country Prediction Lines for the Slope

Post by GeorgeLeckie » Thu Sep 27, 2018 4:48 pm

In your plot, look a the y-axis (where x = 0). You should seed that the higher intercepts generally have negative slopes. The lower intercepts generally have positive slopes. This is what we expect given a negative covariance. The stronger the correlation, the more pronounced the pattern. The lines fan in at this point. Moving to the right we see that the lines ultimately cross over.

KazimovHH
Posts: 14
Joined: Mon Apr 09, 2018 11:56 am

Re: Random Slope Model Country Prediction Lines for the Slope

Post by KazimovHH » Thu Sep 27, 2018 5:40 pm

Dear George,

Thank you very much for the feedback.
Regards,
Rza

Post Reply