Hey David,

when I used your suggested formula: *plm( log(revenue) ~ log(supply) + 
factor(town) + as.numeric(as.character(year)), data=R_Test_log_Neu) *I 
will get the same results as without considering town and year in the 
formula. So this might not the clue for taking into account a linear trend.

Please find attached the results of _str(R_Test_log_Neu):
_

Classes ‘tbl_df’, ‘tbl’ and 'data.frame':       132 obs. of  4 variables:
  $ town   : num  1 1 1 1 1 1 1 1 1 1 ...
  $ year   : num  1 2 3 4 5 6 7 8 9 10 ...
  $ revenue: num  39.9 43.3 44 43.2 39.1 ...
  $ supply : num  1 1 1 1 1 1 35 101 181 323 ...


Hope this is helpful.

Toby



Am 13.05.2017 um 16:40 schrieb David Winsemius:
>> On May 13, 2017, at 4:07 AM, Tobias Christoph <s3toc...@uni-bayreuth.de> 
>> wrote:
>>
>> Hey Peter,
>>
>> thank you. Yes, I want to have "year" in the varibale.
>> But if I use "*town*year*" as a furmula, R will create new factor
>> variable with n levels, where n = (num of towns) x (num of years). What
>> I'm trying to do is create 50 (town x year) variables such that
>> town1xyear is 1,2,3... when town== 1 and zero otherwise, repeat for
>> town2xyear, where state == 2, etc.
>>
>> It is now clear? Sorry for my bad explanations.
> I had suggested that you must provide str(R_Test_log_Neu). I'm still 
> suggesting this would be a good idea.
>
> Since you have not done so, we can only guess at the right course to follow 
> from your reports of problems and errors. Peter pointed out that the `time` 
> function was in the 'stats' package (not from plm or elsewhere as I 
> imagined). You are implying that 'year' is currently a factor value with 
> levels that appears as the character versions of integers.
>
> You may be able to get closer to what is possible by using:
>
> plm( log(revenue) ~ log(supply) + factor(town) + 
> as.numeric(as.character(year)),
>       data=R_Test_log_Neu)
>
> This should fix the problem noted by Peter and avoid the potentially 
> incorrect construction of the desired linear trend.
>
> If you used the interaction operator "*" between 'town' and the numeric 
> version of 'year' it will give you two sets of coefficients involving 'town'. 
> The first set will be the mean deviations from the base factor level. The 
> other set will be the differences in slopes for the time trends for each of 
> the (factored) towns from the overall time trend/slope. And for your data you 
> wouldbe constructing a saturated model ... as you observed in your first 
> message (which remains in the copied thread below).
>


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to