Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: writing mata code more effeciently


From   "AbdelRahmen El Lahga" <[email protected]>
To   <[email protected]>
Subject   st: writing mata code more effeciently
Date   Tue, 21 Feb 2006 01:02:36 +0100

Is there any solution to rewrite this fragment of my mata code more
efficiently. My old laptop runs more then 1 hours without finishing  the job
on 50591 obs.
below the code:
version 9.1
mata:
mata clear
void fe () {
stata ("drop _all")
stata ("use c:\data\nicolas\select\sas\testing")
y_init=x_init=s_init=.
st_view(y_init, .,  "f_week_hours")
st_view(x_init, ., ("f_lnwage", "m_lnwage", "assetinc"))
st_view(s_init, ., "s_init")
tmax=21 // tmax
n=rows(x_init)/tmax  // nombre d'individus
nt=rows(x_init)         //nombre total des lignes
k=cols(x_init)           // nombre de regresseurs
k
y=J(nt,1,0)
x=J(nt,k,0)
s=s_init
for (i=1;i=nt;i++) {
if (s[i]=1) {
y[i,.]= y_init[i,.]
x[i,.]= x_init[i,.]
}
}
}
fe ()
end
PS: When i use st_data instead of st_view I get the follwing error:
 fe():  3257  nonpointer found where pointer required
                 <istmt>:     -  function returned error
Any help

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index