Skip to content

Commit 043f02d

Browse files
another small bug
1 parent b3ef13f commit 043f02d

File tree

2 files changed

+30
-29
lines changed

2 files changed

+30
-29
lines changed

R/fit_basset.R

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ basset <- function(Y=NULL, X, upsilon=NULL, Theta=NULL, Gamma=NULL, Xi=NULL, lin
9292
stop("Theta and Gamma must be of the same length.")
9393
}
9494

95-
## setting newdata <- X if newdata is null
96-
if(is.null(newdata)){
97-
newdata <- X
98-
}
99-
10095
## evaluating theta and gamma
10196
## theta
10297
theta_eval <- function(Theta, X, linear){
@@ -139,6 +134,7 @@ basset <- function(Y=NULL, X, upsilon=NULL, Theta=NULL, Gamma=NULL, Xi=NULL, lin
139134
Gamma_comb <- Reduce('+', Gamma_trans)
140135

141136
## fitting the joint model
137+
## newdata auto handled by pibble
142138
collapse_samps <- pibble(Y, X=diag(ncol(X)), upsilon, Theta_comb, Gamma_comb, Xi, init, pars, newdata = newdata, ...)
143139

144140
## fitting uncollapse using the joint samples
@@ -176,6 +172,11 @@ basset <- function(Y=NULL, X, upsilon=NULL, Theta=NULL, Gamma=NULL, Xi=NULL, lin
176172
}
177173
}
178174

175+
## setting newdata <- X if newdata is null
176+
if(is.null(newdata)){
177+
newdata <- X
178+
}
179+
179180
for(i in 1:num.comp){
180181
## if num.comp == 1 --> return the samples from Lambda above
181182
if(num.comp == 1){

vignettes/non-linear-models.Rmd

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -145,30 +145,30 @@ predicted <- predict(fit.clr, X_predict, jitter=1)
145145
Now I am going to create a visual that shows the observed data in CLR coordinates
146146
(to do that I will need to add a pseudo-count) along with the smoothed estimates.
147147
```{r fig.height=5, fig.width=7}
148-
# family_names <- as(mallard_family$tax_table$Family, "vector")
149-
# Y_clr_tidy <- clr_array(Y+0.65, parts = 1) %>%
150-
# gather_array(mean, coord, sample) %>%
151-
# mutate(time = X[1,sample],
152-
# coord = paste0("CLR(", family_names[coord],")"))
153-
#
154-
# predicted_tidy <- gather_array(predicted, val, coord, sample, iter) %>%
155-
# mutate(time = X_predict[1,sample]) %>%
156-
# filter(!is.na(val)) %>%
157-
# group_by(time, coord) %>%
158-
# summarise_posterior(val, na.rm=TRUE) %>%
159-
# ungroup() %>%
160-
# mutate(coord = paste0("CLR(", family_names[coord],")"))
161-
#
162-
# ggplot(predicted_tidy, aes(x = time, y=mean)) +
163-
# geom_ribbon(aes(ymin=p2.5, ymax=p97.5), fill="darkgrey", alpha=0.5) +
164-
# geom_ribbon(aes(ymin=p25, ymax=p75), fill="darkgrey", alpha=0.9)+
165-
# geom_line(color="blue") +
166-
# geom_point(data = Y_clr_tidy, alpha=0.5) +
167-
# facet_wrap(~coord, scales="free_y") +
168-
# theme_minimal()+
169-
# theme(axis.title.y = element_blank(),
170-
# axis.title.x = element_blank(),
171-
# axis.text.x = element_text(angle=45))
148+
family_names <- as(mallard_family$tax_table$Family, "vector")
149+
Y_clr_tidy <- clr_array(Y+0.65, parts = 1) %>%
150+
gather_array(mean, coord, sample) %>%
151+
mutate(time = X[1,sample],
152+
coord = paste0("CLR(", family_names[coord],")"))
153+
154+
predicted_tidy <- gather_array(predicted, val, coord, sample, iter) %>%
155+
mutate(time = X_predict[1,sample]) %>%
156+
filter(!is.na(val)) %>%
157+
group_by(time, coord) %>%
158+
summarise_posterior(val, na.rm=TRUE) %>%
159+
ungroup() %>%
160+
mutate(coord = paste0("CLR(", family_names[coord],")"))
161+
162+
ggplot(predicted_tidy, aes(x = time, y=mean)) +
163+
geom_ribbon(aes(ymin=p2.5, ymax=p97.5), fill="darkgrey", alpha=0.5) +
164+
geom_ribbon(aes(ymin=p25, ymax=p75), fill="darkgrey", alpha=0.9)+
165+
geom_line(color="blue") +
166+
geom_point(data = Y_clr_tidy, alpha=0.5) +
167+
facet_wrap(~coord, scales="free_y") +
168+
theme_minimal()+
169+
theme(axis.title.y = element_blank(),
170+
axis.title.x = element_blank(),
171+
axis.text.x = element_text(angle=45))
172172
173173
```
174174

0 commit comments

Comments
 (0)