【发布时间】:2015-10-06 10:46:15
【问题描述】:
这是该图中使用的我的数据框中的数据子集;
Year region gear Species.Code query LPUE
1974 Cyprus creel LOB Pre 0.31
1975 Cyprus creel LOB Pre 0.26
1976 Cyprus creel LOB Pre 0.33
1977 Cyprus creel LOB Pre 0.17
1978 Cyprus creel LOB Pre 0.2
1979 Cyprus creel LOB Pre 0.22
1980 Cyprus creel LOB Pre 0.38
1981 Cyprus creel LOB Pre 0.51
1982 Cyprus creel LOB Pre 0.57
1983 Cyprus creel LOB Pre 0.45
1984 Cyprus creel LOB Post 0.43
1985 Cyprus creel LOB Post 0.33
1986 Cyprus creel LOB Post 0.21
1987 Cyprus creel LOB Post 0.69
1988 Cyprus creel LOB Post 0.65
1989 Cyprus creel LOB Post 0.37
1990 Cyprus creel LOB Post 0.35
1991 Cyprus creel LOB Post 0.15
1992 Cyprus creel LOB Post 0.21
1993 Cyprus creel LOB Post 0.17
我已经生成了时间序列数据的线图,并拟合了两个线性回归,一个用于 1984 年之前的数据,一个用于 1984 年之后的数据。 使用以下代码;
ggplot(subset(A7,region=="Cyprus"&gear=="creel"&Species.Code=="LOB"),aes(x=Year,y=LPUE,shape=query))+
geom_line()+
geom_smooth(method="lm")+
theme(panel.background = element_rect(fill = 'white', colour = 'black'))
首先我想知道如何在绘图上打印方程式(我在堆栈溢出中发现的其他示例仅处理一个 lm),其次我想知道如何保存 lm 模型以便我可以进行统计测试他们之间的意义。
【问题讨论】:
-
您拥有的内容的屏幕截图会有所帮助,因为您可能没有包含足够的数据来重现您拥有的内容。
-
如果你想做统计测试,我建议在 ggplot 之外拟合模型。
-
抱歉@MikeWise 我不熟悉如何添加屏幕截图。我只能看到如何添加来自互联网的图像。
标签: r ggplot2 regression