This function is a wrapper for scaling the fitted (predicted) values of a one-sided (positive or negative only) integer response variable of supported models. The scaling involves some log transformation of the fitted (predicted) values.
Arguments
- x
The parameter to be scaled, which is the fitted values from supported models. The scaled parameter is used mainly for constrained forecasting of a response variable positive (0 - inf) or negative (-inf - 0). The scaling involves log transformation of the parameter
- lower
Integer or variable representing the lower limit for the scaling (-inf or 0)
- upper
Integer or variable representing the upper limit for the scaling (0 or inf)
Examples
library(Dyn4cast)
library(splines)
lower <- 1
upper <- 37
Model <- lm(states ~ bs(sequence, knots = c(30, 115)), data = Data)
scaledlogit(x = fitted.values(Model), lower = lower,
upper = upper)
#> 1 2 3 4 5 6 7 8 9 10
#> -2.8342 -3.0126 -3.1861 -3.3486 -3.4918 -3.6058 -3.6807 -3.7096 -3.6911 -3.6299
#> 11 12 13 14 15 16 17 18 19 20
#> -3.5351 -3.4170 -3.2851 -3.1466 -3.0065 -2.8684 -2.7341 -2.6048 -2.4811 -2.3632
#> 21 22 23 24 25 26 27 28 29 30
#> -2.2511 -2.1445 -2.0435 -1.9476 -1.8567 -1.7706 -1.6891 -1.6119 -1.5390 -1.4702
#> 31 32 33 34 35 36 37 38 39 40
#> -1.4054 -1.3441 -1.2861 -1.2309 -1.1784 -1.1282 -1.0803 -1.0343 -0.9903 -0.9479
#> 41 42 43 44 45 46 47 48 49 50
#> -0.9072 -0.8680 -0.8302 -0.7937 -0.7585 -0.7245 -0.6917 -0.6598 -0.6291 -0.5993
#> 51 52 53 54 55 56 57 58 59 60
#> -0.5704 -0.5424 -0.5153 -0.4891 -0.4636 -0.4389 -0.4150 -0.3918 -0.3693 -0.3475
#> 61 62 63 64 65 66 67 68 69 70
#> -0.3263 -0.3058 -0.2860 -0.2667 -0.2481 -0.2300 -0.2126 -0.1957 -0.1793 -0.1635
#> 71 72 73 74 75 76 77 78 79 80
#> -0.1483 -0.1336 -0.1193 -0.1056 -0.0924 -0.0797 -0.0675 -0.0557 -0.0445 -0.0336
#> 81 82 83 84 85 86 87 88 89 90
#> -0.0233 -0.0134 -0.0039 0.0051 0.0137 0.0219 0.0296 0.0370 0.0439 0.0504
#> 91 92 93 94 95 96 97 98 99 100
#> 0.0566 0.0623 0.0677 0.0726 0.0773 0.0815 0.0854 0.0889 0.0921 0.0949
#> 101 102 103 104 105 106 107 108 109 110
#> 0.0974 0.0995 0.1013 0.1029 0.1040 0.1049 0.1055 0.1058 0.1057 0.1054
#> 111 112 113 114 115 116 117 118 119 120
#> 0.1048 0.1040 0.1028 0.1014 0.0998 0.0979 0.0957 0.0933 0.0907 0.0878
#> 121 122 123 124 125 126 127 128 129 130
#> 0.0846 0.0813 0.0777 0.0738 0.0698 0.0655 0.0610 0.0562 0.0512 0.0461
#> 131 132 133 134 135 136 137 138 139 140
#> 0.0407 0.0350 0.0292 0.0232 0.0169 0.0105 0.0039 -0.0030 -0.0100 -0.0173
#> 141 142 143 144 145 146 147 148 149 150
#> -0.0247 -0.0323 -0.0402 -0.0482 -0.0564 -0.0647 -0.0733 -0.0820 -0.0909 -0.1000
#> 151 152 153 154 155 156 157 158 159 160
#> -0.1093 -0.1187 -0.1283 -0.1381 -0.1481 -0.1582 -0.1685 -0.1789 -0.1895 -0.2003
#> 161 162 163 164 165 166 167 168 169 170
#> -0.2112 -0.2223 -0.2335 -0.2449 -0.2565 -0.2682 -0.2801 -0.2921 -0.3043 -0.3166
#> 171 172 173 174 175 176 177 178 179 180
#> -0.3291 -0.3417 -0.3544 -0.3674 -0.3804 -0.3937 -0.4070 -0.4205 -0.4342 -0.4480
#> 181 182 183 184 185 186 187 188 189 190
#> -0.4620 -0.4761 -0.4903 -0.5047 -0.5193 -0.5340 -0.5488 -0.5638 -0.5790 -0.5943
#> 191 192 193 194 195 196 197 198 199 200
#> -0.6097 -0.6253 -0.6411 -0.6570 -0.6731 -0.6893 -0.7057 -0.7222 -0.7389 -0.7558