Hi,
I'm having trouble getting through this. I have the following class
I then have a file test.do that does the following
In the initialization of the object (class), I get the following error and can't do anything else:
Why am I getting this error? Is this not how you're supposed to initialize an object? Is it because I'm trying to use the object in interactive mode?
I'm having trouble getting through this. I have the following class
Code:
version 15
set matastrict on
mata:
class nelogit
{
protected:
real matrix X, S // explanatory variables and scale variables
real colvector y // vector of the dependent variable
real scalar j // number of alternatives
public:
void setup()
}
// Setup functions for the class
void nelogit::setup(real colvector user_y,
real matrix user_X,
real scalar user_j,
| real matrix user_S)
{
y = user_y
X = user_X
j = user_j
if (args()>3) S = user_S
}
end
Code:
version 15 local pdir "/Users/alfonso/Dropbox/My Documents/Programming/Stata/ado/nelogit/Classes" cap mata: mata drop nelogit() quiet do "`pdir'/nelogit.mata" // Loading data set local ddir "/Users/alfonso/Dropbox/Academia/My Research/My Articles/Health Mixed Logit/Stata Files" use "`ddir'/Data/estimationdata", clear // Getting rid of invalid observations drop if missing(Answer, Income) // Macro with the explanatory variables local xvars "c1 c2 bmi1 bmi2 inc1 inc2 new1 new2 labin1 labin2 Cal Sug Sod Fat Price Serv Brand" set matastrict on mata: class nelogit scalar nl nl.setup(st_data(.,"`xvars'"), st_data(.,"choice"), 3) end
Code:
mata:
------------------------------------------------- mata (type end to exit) ------------------------------------------------------------------------------------------------
:
: class nelogit scalar nl
nothing found where '(' expected
(3 lines skipped)
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
r(3000);
end of do-file
r(3000);

Comment