broom :: augment:评估错误:gamlss找不到对象但是lm都很好

时间:2018-03-06 00:24:29

标签: r dplyr tidyverse broom gamlss

我正在努力将<script> $(document).ready(function() { $("input[name$='src']").click(function() { var test = $(this).val(); $("div.desc").hide(); $("#src" + test).show(); }); }); </script> <Input type = 'Radio' Name ='src' value= 'sr'>SR<p> <Input type = 'Radio' Name ='src' value= 'C'>C <p><p> <div id="st" class="desc"> SR: <select name="sp" id="SR" visible="false"> <option selected="selected">All</option> <?php foreach ($qry2 as $SR) { ?> <option value="<?= $SR->SR ?>"><?= $SR->SR ?></option> <?php }; ?> </select> </div> <div id="c" class="desc" visible="false"> C: <select name="C" id="C"> <option selected="selected">All</option> <?php foreach ($qry1 as $name) { ?> <option value="<?= $name->C ?>"><?= $name->C ?></option> <?php }; ?> </select> </div> 结果收集到数据框中。这继续示例here

使用gamlss

的工作示例
lm

使用library(tidyverse) library(broom) library(gamlss) library(datasets) # working mro <- mtcars %>% nest(-am) %>% mutate(am = factor(am, levels = c(0, 1), labels = c("automatic", "manual")), fit = map(data, ~lm(mpg ~ hp + wt + disp, data = .)), results = map(fit, augment))

的示例破损
gamlss

感谢任何提示或提示。

1 个答案:

答案 0 :(得分:0)

到目前为止,这是我发现的最优雅的方法(反复试验)。很高兴能够得到纠正。

aug_func <- function(df){
          augment(gamlss(mpg ~ hp + wt + disp, data=df))
        }
mtcars %>% 
  mutate(am = factor(am, levels = c(0, 1), labels = c("automatic", "manual"))) %>%
  group_by(am) %>%
  do(aug_func(df=.)) %>%
    ggplot(aes(x = mpg, y = .fitted)) +
      geom_abline(intercept = 0, slope = 1, alpha = .2) +  # Line of perfect fit
      geom_point() +
      facet_grid(am ~ .) +
      labs(x = "Miles Per Gallon", y = "Predicted Value") +
      theme_bw()

enter image description here