Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Offset variable
From
"Stephen A. Crowder" <[email protected]>
To
"<[email protected]>" <[email protected]>
Subject
st: Offset variable
Date
Mon, 9 Dec 2013 03:53:36 +0000
I am developing an ordinal logistic regression model examining a factor with several levels on my dependent variable. That part is straight forward enough but I have a main independent variable that ide like to control for in the examination of all of the other independent variables. My question is would I need to make this an "offset variable" in my models? I've been looking through the literature and there's no clear answer available.
Sent from my iPhone
> On Dec 8, 2013, at 12:58 PM, "Nick Cox" <[email protected]> wrote:
>
> Your code does not define any -O- before you call Mata. So, Mata
> doesn't know what you are referring to. You can't refer in advance to
> what doesn't yet exist.
>
> What I think you want to do is pass a string to be used as the name of
> the thing you want to create. That would be need to shown as such e.g.
> "O" and your Mata would need to expect a string scalar as argument.
>
> That said, your Mata code so far just creates a matrix in Mata. That
> does nothing in terms of anything in Stata. It appears that you have
> Stata objects and Mata objects, but they are not at all the same.
>
> You could back up and describe the precise problem you want to solve.
> It is not at all clear that you need Mata to do it.
>
> It's also a stretch at best and impossible at worst, for Mata to
> understand Stata's local macros.
>
> As above, there is no "MATA". It is "Mata".
>
> Nick
> [email protected]
>
>
>> On 8 December 2013 18:31, Jason Park <[email protected]> wrote:
>> Dear users,
>>
>> Thanks to one of the previous threads
>> (http://www.stata.com/statalist/archive/2011-01/msg00393.html), I've
>> come to understand that, in a do file, mata should be moved outside of
>> a loop to before the loop so that the loop can call it.
>> However, the thread only shows the case where input is a scalar.
>> Instead, I want the name of a matrix that mata returns as a result,
>> say O, to be the parameter of the mata function. As shown below, the
>> mata function I want my loops to call is a matrix presentation of some
>> detailed calculation of the outputs of VAR results.
>>
>> * beginning of the do file
>> clear all
>> mata
>> void foobar(O) {
>> L = ("aa"\"bb")
>> M = J(2, 1, .)
>> M[1,1] = `aa'
>> M[2,1] = `bb'
>> O = L,M
>> }
>> end
>>
>> foreach case in "date<=10" "date>10&date<=20" "date>20" {
>> ma drop aa
>> ma drop bb
>> local aa = 0
>> local bb = 0
>> forvalues i = 1/10
>> var a b if id == `i' & `case', lags(1/2)
>> ma drop B
>> ma B = e(b)
>> local aa = `aa' + B[1,1]
>> local bb = `bb'+ B[1,6]
>> mata foobar(O)
>> }
>> * end of the do file
>>
>> This code returns:
>> <istmt>: 3499 O not found
>> r(3499);
>>
>> Could anyone provide some tips?
>>
>> Thanks in advance,
>> J
>> *
>> * For searches and help try:
>> * http://www.stata.com/help.cgi?search
>> * http://www.stata.com/support/faqs/resources/statalist-faq/
>> * http://www.ats.ucla.edu/stat/stata/
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
>
Individuals who have received this information in error or are not authorized to receive it must promptly return or dispose of the information and notify the sender. Those individuals are hereby notified that they are strictly prohibited from reviewing, forwarding, printing, copying, distributing or using this information in any way.
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/