Skip to content

Commit 3a4704d

Browse files
runnerrunner
authored andcommitted
Re-build README.Rmd
1 parent f2b8e1f commit 3a4704d

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ knots = createKnots(values = x, n_knots = 20, degree = 3)
4949
# Create basis using that knots:
5050
basis = createSplineBasis(values = x, degree = 3, knots = knots)
5151
str(basis)
52-
#> num [1:100, 1:24] 0.1667 0.1352 0.0832 0.0755 0.0609 ...
52+
#> num [1:100, 1:24] 0.16667 0.11991 0.0209 0.00524 0 ...
5353

5454
# You can also create sparse matrices:
5555
basis_sparse = createSparseSplineBasis(values = x, degree = 3, knots = knots)
5656
str(basis_sparse)
5757
#> Formal class 'dgCMatrix' [package "Matrix"] with 6 slots
58-
#> ..@ i : int [1:398] 0 1 2 3 4 5 6 7 0 1 ...
59-
#> ..@ p : int [1:25] 0 8 23 40 65 87 108 130 147 164 ...
58+
#> ..@ i : int [1:398] 0 1 2 3 0 1 2 3 4 5 ...
59+
#> ..@ p : int [1:25] 0 4 12 25 42 60 77 93 111 131 ...
6060
#> ..@ Dim : int [1:2] 100 24
6161
#> ..@ Dimnames:List of 2
6262
#> .. ..$ : NULL
6363
#> .. ..$ : NULL
64-
#> ..@ x : num [1:398] 0.1667 0.1352 0.0832 0.0755 0.0609 ...
64+
#> ..@ x : num [1:398] 0.16667 0.11991 0.0209 0.00524 0.66667 ...
6565
#> ..@ factors : list()
6666

6767
# Check if row sums add up to 1:
@@ -141,9 +141,9 @@ of freedom to a penalty term:
141141
``` r
142142
# We use the basis and penalty matrix from above and specify 2 and 4 degrees of freedom:
143143
(penalty_df2 = demmlerReinsch(t(basis) %*% basis, K, 2))
144-
#> [1] 1.02076e+11
144+
#> [1] 19061925739
145145
(penalty_df4 = demmlerReinsch(t(basis) %*% basis, K, 4))
146-
#> [1] 439.9171
146+
#> [1] 438.4036
147147

148148
# This is now used for a new estimator:
149149
beta_df2 = myEstimator(basis, y, penalty_df2 * K)
@@ -252,12 +252,12 @@ idx = calculateIndexVector(x, bins) + 1
252252

253253
head(data.frame(x = x, bins = bins[idx]))
254254
#> x bins
255-
#> 1 0.3159971 0.3159971
256-
#> 2 0.3469970 0.3159971
257-
#> 3 0.4110397 0.3159971
258-
#> 4 0.4226494 0.3159971
259-
#> 5 0.4469811 0.3159971
260-
#> 6 0.5170778 0.6488035
255+
#> 1 0.1315894 0.1315894
256+
#> 2 0.1799150 0.1315894
257+
#> 3 0.3638408 0.4682956
258+
#> 4 0.4497893 0.4682956
259+
#> 5 0.6709395 0.8050017
260+
#> 6 0.6744560 0.8050017
261261
```
262262

263263
For spline regression, we can build the basis just using the bins and

0 commit comments

Comments
 (0)