Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Linear regression model of log variable conc over time

    I have to perform a linear regression of conc (natural log) over time separatedly for each participant (id) and diet. (eg participant 1, diet = meat; participant 1, diet = nomeat; participant 2, diet = meat, etc.)

    I am given the dataset for the coefficient for variable time from linear regression output (times -1), known as ext and predicted concentration from linear regression output, known as pre.

    I am supposed to generate ext_2 and pre_2 to check that ext and pre are calculated correctly.

    The equation of the linear regression is as follows: ln conc = beta naught + beta one x time

    beta one = ext variable

    So far I have tried the following:

    Code:
    gen lnconc = ln(conc)
    > Generate the natural log variable for conc

    Code:
    regress lnalcohol time id if diet == "meat"
                regress lnalcohol time id if diet == "nomeat"
    > Fit linear regression model (where I am stucked at)

    Code:
    predict pre_2, xb
    > predicted conc for the output, but does not return the same values as shown in pre

    Code:
    matrix a = r(table)
    local est = a[a,b];
    > ext variable for coefficient, but had a syntax error when i tried the second line of code (also stucked at this)

    Looking forward to some advice~
    Last edited by Goh jedrek; 01 Jun 2021, 10:31.
Working...
X