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:
> Generate the natural log variable for conc
> Fit linear regression model (where I am stucked at)
> predicted conc for the output, but does not return the same values as shown in pre
> 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~
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)
Code:
regress lnalcohol time id if diet == "meat" regress lnalcohol time id if diet == "nomeat"
Code:
predict pre_2, xb
Code:
matrix a = r(table) local est = a[a,b];
Looking forward to some advice~