对包含零的时间序列数据进行对数回归吗? (使用R工具)

时间:2013-01-12 04:30:27

标签: r regression logarithm

https://dl.dropbox.com/u/53624395/11.csv

这是时间序列数据,我必须执行形式y=a+b(log(x1))+c(log(x2))的对数回归并找到a,b,c,然后检查是否存在任何此类关系。 我必须使用R工具执行此操作。我已经在http://stats.stackexchange.com上发布了这个问题,但它已被关闭,因为它应该发布在StackOverflow上,因为它与R编程完全相关。请帮助。

数据:

structure(list(x = c(433.66, 433, 230, 0, 251, 0, 424, 0, 439, 
0, 0, 0, 0, 85.15, 0, 0, 748, 0, 732, 0, 523.76, 0, 780, 0, 778, 
0, 635.64, 0, 600, 0), y = c(9.9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), 
z = c(43504.95, 49380, 50601, 0, 36064, 0, 47081, 0, 43775, 
0, 0, 0, 0, 85.15, 0, 0, 68502, 0, 66397, 0, 47565.35, 0, 
65695, 0, 69111, 0, 53213.86, 0, 118891, 0), x1 = c(1382.18, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1306, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), x2 = c(0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0, 1473.27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0, 0, 0, 0, 0, 0, 0), x3 = c(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 
2, 3, 2.1, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
0), x4 = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 2L, 1L, 5L, 
43L, 11L, 2L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 
0L, 0L, 0L, 0L)), .Names = c("x", "y", "z", "x1", "x2", "x3", 
"x4"), class = "data.frame", row.names = c(NA, -30L))

1 个答案:

答案 0 :(得分:2)

要求做的事是不可能的。但你可以近距离接触。

试试这个:y = a + b(log(x1 + 1)) + c(log(x2 + 1))

命名您的数据框x

x <- read.csv('11.csv')

lm(y ~ 1 + log(x1+1) + log(x2+1), data=x)

## Call:
## lm(formula = y ~ 1 + log(x1 + 1) + log(x2 + 1), data = x)
##
## Coefficients:
## (Intercept)  log(x1 + 1)  log(x2 + 1)  
##  -1.202e-04    1.312e+00    1.648e-05