Guest User

Untitled

a guest
Dec 10th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. library(dplyr)
  2. library(tidyr)
  3. dummy_fun <- function(x, alpha){
  4. return(sum((x %>% unnest)^alpha))}
  5.  
  6.  
  7. dummy_data <- data.frame(id = c(rep(c(1:8), times = c(10,12,8,13,7,8,10,12))), x = rnorm(80)) %>%
  8. group_by(id) %>%
  9. nest() %>%
  10. ungroup()%>%
  11. rowwise %>%
  12. mutate(y = dummy_fun(data, 2)) %>%
  13. ungroup()%>%
  14. rename(obs = data)
  15.  
  16. nls.test <- nls(y ~ dummy_fun(x = obs , alpha), data = dummy_data, start = list(alpha = 1.5))
Add Comment
Please, Sign In to add comment