0
votes

I have a data set where I am interested in changes in lambda over time but I have years since detection as my x axis instead of a traditional time series date variable. I have tried running it in packaged segmented which works but I think changepoint is more what I am looking for in terms of assessing when the population goes from steady to period of decrease (loglambda<0) and back to increasing/steady. Below is an example of my data: lines are hand drawn to show the three separate expected means that I want to estimate the breakpoints for which here would be between 0 and 3.enter image description here

I don't know how to do this in the package changepoint as it seems to want a timeseries type dataset.
Subset of data:

        ysw  lambdalog
1       12  0.0777704088
2       -1  0.0770295351
3        1 -0.7137508637
4      -21  0.1900608470
5       -1 -0.7246886455
6      -16  0.3981136917
7       -4 -0.4338304420
8        3 -1.2649336503
9      -25  0.0259855251
10     -23  0.3051055887
11       4 -0.0574958938
12       3 -0.1187091258
13       1 -1.1600080284
14      -7  0.1409314001
15      -9 -0.2445836355
16       0  0.2432861461
17       0 -0.2148360928
18      -1  0.0004340775
19       1 -0.5650091926
20       1 -0.1150294631
21     -17  0.0096000836
22       3 -1.1972262747
23       5  0.2816615496
24       0  0.0430262698
25      11  0.0004340775
26       2 -0.5214335044
27      -1  0.0884000848
28       3  0.3681628716
29       8 -0.0210967888
30       0  0.5352398525
31       3 -1.4642840300
32       1  0.0004340775
33      -1  0.0940950522
34       2 -0.3971574115
35       2 -0.9956786262
36      -6  0.3548977827
37       2 -0.4992292576
38       0  0.0461481798
39       4  0.0004340775
40      -1  0.0004340775
41       6  0.0004340775
42       3 -0.3001622741
43       1 -0.4860085597
44     -23  1.4471735416
45     -10  0.2247239238
46       1  0.5086513178
47       4  0.0181454897
48      -9  2.1820531165
49       1 -0.3709944386
50       4 -0.3001622741
51     -12 -0.0126803424
52       5  0.3012470886
53       1  0.3012470886
54       1 -0.6727233248
55     -17  0.0004340775
56      -2  0.0669668009
57       3 -0.2408783417
58       0  1.0414321647
59      -9 -0.1900392355
60     -19  0.2043913319
61      -3 -0.4884210574
62       0  0.1954389020
63      -1 -0.9422285548
64       1 -0.3550108256
65     -13 -0.1882981847
66       5 -0.0428658121
67       1 -0.4987729697
68      -3  0.3012470886
69       4 -0.4379410780
70     -30  0.8625317410
71       4 -0.1849711688
72      -1 -1.5635862431
73       3 -0.4053508494
74     -24  0.0577467655
75       1 -0.2189467475
76      12 -0.0464827200
77      -1  0.0040346161
78       0 -0.2277449898
79       0 -0.0669186751
80      -1 -0.1499012466
81       6 -0.2378090579
82     -30 -0.6241236143
83       0  0.0296131291
84      -5  0.7386399111
85      -2  0.2225126258
86      -4  0.0430055713
87      10  0.0685312345
88       0 -0.1587701220
89      -9  0.0191534873
90       0 -0.1754403054
91       2 -0.0997964995
92      -4  0.0004340775
93     -23 -0.2814436084
94       6  0.4066269892
95      -7 -0.0037022192
96     -15  0.0149178196
97     -15 -0.0469489904
98       5 -0.0836857170
99      -4  0.0004340775
100     -6  0.0905905045
101      1  0.2823624589
102      4 -0.3001622741
103      5  0.2590217867
104      1 -0.2008730497
105      0  0.3012470886
106     -2  0.1950389171
107      5  0.3012470886
108     -1 -0.4015469848
109     -1  0.2528176993
110      4  0.0004340775
111    -26  0.3599167362
112    -24  0.0076980924
113     -2  0.0141469324
114    -18  0.8759344724
115     13  0.0254955590
116    -11 -0.2157805125
117      2  1.5563145643
118     -5  0.0223833409
119     -3 -0.1297478663
120     10  0.0406414247
121      6  0.0255622223
122      2 -0.3512064532
123      5 -0.0822453776
124    -18  0.0756225421
125      5  0.0004340775
126     -3  0.3012470886
127      6  0.2469183638
128      6 -0.2272325059
129      0  0.1930297163
130      7  0.1324193887
131     -3 -0.0973868772
132      2 -0.1982838668
133      6 -0.0926580885
134      5 -0.3001622741
135     -5  0.0462757611
136      4  0.0004340775
137      2 -0.5893741528
138     -1  0.0004340775
139    -21  0.1234557127
140     -3  0.1394294585
141    -16 -0.2690270814
142     -4  0.3012470886
143      5  0.0004340775
144      0  1.5250577709
145     -5  0.0488432777
146      4  0.3935197874
147     -1 -0.0053934215
148    -22  0.5948283354
149    -15  0.1390473917
150      2 -0.1866357167
151     -4 -0.0430610621
152      2 -0.1892155438
153      9 -0.1499012466
154      3 -0.4214015022
155     -2 -0.0487318850
156    -23  0.0120547832
157     -1 -0.6683860010
158     -2  0.0894342011
159     -6  0.1151124632
160      2 -0.3361253830
161      6 -0.3880131261
162     -6 -0.1499012466
163      1 -0.6968039426
164      4  0.0004340775
165     -4  0.2115226048
166      5 -0.0330045563
167      0  0.1520380386
168      7  0.0004340775
169      8 -0.0055095496
170      4 -0.3001622741
171    -20 -0.0602602896
172      3 -0.9935177778
173     10 -0.0425250496
174     -4  0.0765606477
175      0  0.3012470886
176     -2  0.0966187956
177      0  0.0065857198
178      6  0.4772659954
179     -3  0.0004340775
180    -23 -0.1103640646
181    -18  0.2984908143
182      7  0.0590763119
183     -7  0.1319413467
184      3 -0.3001622741
185      4 -0.4108344721
186      0  0.1406326927
187     -2 -0.1864190114
188      3  0.0004340775
189      3 -0.1754403054
190     12  0.0678996305
191      6 -0.1187091258
192     -8 -0.0025173908
193      5  0.0004340775
194     -6 -0.0027023076
195      3 -0.3791701837
196     -4 -0.4301529323
197      1 -0.7755532697
198      7  0.3012470886
199     -9  0.0292625869

library(changepoint)
fit_changepoint = cpt.meanvar(a1$lambdalog)
# Return estimates
c(ints = param.est(fit_changepoint)$mean,
  cp = cpts(fit_changepoint))
plot(fit_changepoint)

I get:

The figure makes no sense regarding time. Is there a way to do this with my dataset?

enter image description here