Hi everybody,
I am trying to use the mnps command in stata to access twang to generate propensity scores for a dataset with more than 2 treatment/exposure arms. I am following this tutorial https://cran.r-project.org/web/packa...ettes/mnps.pdf and have based my code on the example code provided.
The same code works perfectly if I run it with a binary treatment variable and the ps command. However, when I use my multi treatment variable (with 7 treatment arms), I can not create a summary table using the "balance, unweighted weighted" command after I execute the code, but get the error message (111) _var not found.
I am currently assuming that the reason for this error is I..
1) have an old version of stata (stata 13) and the black box that makes stata talk with R has some code that stata does not have
2) do not have enough memory or other computer-hardware limitations that make this variable go lost
3) The 7 arms result in too many calculation steps so that the _var that stata is not looking for gets dropped along the way.
Being the stata-illiterate I am, I have spent a week now trying to figure this out, and I am aware that if it is 3), then there is most probably a super simple solution that involves changing code of the ado file to make stata save the variables it needs outside the memory, but I can not do that and so I hope you can help me. Thanks!
this is my code for the maros:
clear all
* location of adofiles
global ado "C:\Users\Tessa\Desktop\RV288-2019\twang\RAND_TL170\ado files"
* location of datasets
global data "C:\Users\Tessa\Desktop\RV288-2019\twang\RAND_TL170\data"
* location to put output
global objpath "C:\Users\Tessa\Desktop\RV288-2019\twang\RAND_TL170\MNPS output"
* set objpath as the working directory
cd "$objpath"
* location of Rscript (in Mac OS-X use "Rscript")
global RScript "C:\Program Files\R\R-3.6.0\bin\Rscript.exe"
* add location of ado files to adopath
adopath + "$ado"
* read in dataset
use "C:\Users\Tessa\Desktop\RV288-2019\twang\RAND_TL170\data\MNPS.dta", clear
This is the coutpt I get.
. mnps v2siteidPS v2marital age v2gender /*
> */hiv_yr JOP drinkwk smokdri EDU2 v2electric /*
> */prov adult v2howfar v2TRAN2 blwt bls2zos bls2uri /*
> */bls2muc bls3bac bls3fev whocountbl3 bltb wt wBMI /*
> */ cd4n lymphn hemog alt, /*
> */ ntrees(3000) intdepth(3) shrinkage(0.01) /*
> */ permtestiters(0) stopmethod(es.mean ks.mean) estimand(ATE)/*
> */ rcmd("$RScript") /*
> */ objpath("$objpath") /*
> */ plotname(mnps_v2siteid_plot.pdf)
Running R script, please wait...
Summary of pairwise comparisons
----------------------------------------------
maxstd~z minp maxks minksp~l
----------------------------------------------
unw 1.629 0 1 0
es_mean 1.321 0 1 0
ks_mean 1.32 0 1 0
----------------------------------------------
Sample sizes and effective sample sizes
-------------------------------------
n essesm~n essksm~n
-------------------------------------
0 100 59.45 66.37
2 100 46.93 46.75
3 100 46.42 44.23
4 100 68.69 67
5 100 57.44 57.26
6 102 60.84 61.13
7 100 55.98 56.04
-------------------------------------
.
end of do-file
. do "C:\Users\Tessa\AppData\Local\Temp\STD00000000.tmp "
. balance, unweighted weighted
variable _var not found
Related Posts with mnsp command to use twang with stata
Using roctab and roccomp functionsHi there, Firstly, I just wanted to say thank you for taking time to read this post. I have perfor…
Cubic age variable in linear regressionHi all, Upon visual inspection of my data, I noticed that my continuous variable, csh_sh, increased…
New to SSC xtheckmanfe - Panel data Fixed effect with selection and endogeneityDear all, Thanks to Prof Baum a new command is available on SSC. I call this xtheckmanfe. This comma…
Delete observations if not completeHi, I have a question about data for my thesis and I'm new with Stata! I have to observe whether o…
Generalized DiD model with multiple periods and groupsHi all, I am estimating the effect on infant mortality (imr) of a health policy implemented on a mu…
Subscribe to:
Post Comments (Atom)
0 Response to mnsp command to use twang with stata
Post a Comment