我正在尝试在MATLAB中执行以下分析:
Delta值为0的直接Oblimin旋转和"Kaiser归一化"
我知道MATLAB有一个叫做rotatefactors的函数,但是没有提到oblimin旋转(既没有"Kaiser Normalization").如何在MATLAB中执行此分析?
更具体地说,我正在尝试在执行此分析时匹配SPSS的确切输出.
在这里,您可以找到SPSS中使用的所有算法:link(请参阅第338页的oblimin旋转).不幸的是,我无法理解方程式,因此在MATLAB中重现它们.
例如,我使用以下数据:
A = magic(10);
writetable(array2table(A),'test.xlsx') % This data can be imported to SPSS
Run Code Online (Sandbox Code Playgroud)
我执行PCA(在相关矩阵上)并仅提取2个因子.以下是在MATLAB中完成的方法,以获得与SPSS(他们称之为"组件矩阵")完全相同的加载矩阵:
[eigvector,eigmatrix] = eig(corr(A));
[~,ind] = sort(diag(eigmatrix),'descend');
eigmatrix = eigmatrix(ind,ind);
eigvector = eigvector(:,ind);
eigvalues = diag(eigmatrix); % Eigeinvalues
loadings = eigvector*sqrt(eigmatrix);
loadings = loadings(:,1:2) % Extract only 2 factors
Run Code Online (Sandbox Code Playgroud)
接下来,我应该loadings使用函数在矩阵上执行旋转rotatefactors,这就是我被卡住的地方.
这是SPSS中的语法:
FACTOR
/VARIABLES A1 A2 A3 A4 A5 A6 A7 A8 A9 A10
/MISSING LISTWISE
/ANALYSIS A1 A2 A3 A4 A5 A6 A7 …Run Code Online (Sandbox Code Playgroud) 我有一个包含3个因子(condition,measure和time)的数据库,并希望使用x轴,颜色/组和线型来绘制它们.
作为示例,我的数据如下所示:
DT <- data.frame(condition = rep(c("control", "experimental"), each = 4),
measure = rep(c("A", "A", "B", "B"), 2),
time = rep(c("pre-test", "post-test"), 4),
score = 1:8)
> DT
condition measure time score
1 control A pre-test 1
2 control A post-test 2
3 control B pre-test 3
4 control B post-test 4
5 experimental A pre-test 5
6 experimental A post-test 6
7 experimental B pre-test 7
8 experimental B post-test 8
Run Code Online (Sandbox Code Playgroud)
我的目标是绘制一个这样的图形:
我试过了: …
我正在尝试将geom_tile使用 构建的图转换ggplot为ggplotly. 然而,瓷砖在情节上是扭曲的。同样的问题也发生在geom_raster.
展示:
library(ggplot2)
library(plotly)
set.seed(1)
n <- 10
X <- data.frame(xcoord = sample(1:10, n, replace = TRUE),
ycoord = sample(1:10, n, replace = TRUE),
value = runif(n))
gg <- ggplot(X) + geom_tile(aes(x = xcoord, y = ycoord, fill = value))
ggplotly(gg)
Run Code Online (Sandbox Code Playgroud)
我发现有些表达式只能在大括号(大括号{ })中使用,例如:
library(dplyr)
3 %>% {3 + .}
3 %>% {ifelse(. < 2, TRUE, FALSE)}
Run Code Online (Sandbox Code Playgroud)
在管道时使用花括号的原则是什么?我们何时应该使用它以及使用哪些表达式?
我正在努力提高输出的可读性.为了避免显示大量数据,显示指向工作空间中特定元素的链接(即变量,表格,图形等)会很好.
这是一张图片来说明这个想法:
也许我们可以使用该disp功能,因为我知道它允许生成到网页或存储在计算机中的文件的超链接.
这在MATLAB中是否可行?
我想应用特定格式或为一系列 Excel 单元格分配一个值,而无需遍历每个单元格。我目前正在使用这个脚本:
from openpyxl import Workbook
from openpyxl.styles import Font
wb = Workbook()
ws = wb.active
## With iterations
# Apply style
for i, rowOfCellObjects in enumerate(ws['A1':'C4']):
for n, cellObj in enumerate(rowOfCellObjects):
cellObj.fill = Font(name='Times New Roman')
# Assign singular value to all cells
for i, rowOfCellObjects in enumerate(ws['A1':'C4']):
for n, cellObj in enumerate(rowOfCellObjects):
cellObj.value = 3
wb.save("test.xlsx")
Run Code Online (Sandbox Code Playgroud)
但我正在寻找一个更短的符号,像这样:
from openpyxl import Workbook
from openpyxl.styles import Font
wb = Workbook()
ws = wb.active
## Without iterations
# Apply style …Run Code Online (Sandbox Code Playgroud) 在尝试部署我的 github 网页时,会间歇性地弹出此错误。我不知道该怎么做,我已经删除并重新创建了存储库,但错误仍然存在。我的所有 github 页面存储库都遇到同样的问题。
这是一个存储库示例: https: //github.com/cnftstats/borgs
Run actions/deploy-pages@v1
Actor: github-pages[bot]
Action ID: 1998855719
Artifact URL: https://pipelines.actions.githubusercontent.com/odmqpuZ7yGar25NNWIM53v9pBjO9vEwDjecGIYtf9ECZfcxi8V/_apis/pipelines/workflows/1998855719/artifacts?api-version=6.0-preview
{"count":1,"value":[{"containerId":359584,"size":14684160,"signedContent":null,"fileContainerResourceUrl":"https://pipelines.actions.githubusercontent.com/odmqpuZ7yGar25NNWIM53v9pBjO9vEwDjecGIYtf9ECZfcxi8V/_apis/resources/Containers/359584","type":"actions_storage","name":"github-pages","url":"https://pipelines.actions.githubusercontent.com/odmqpuZ7yGar25NNWIM53v9pBjO9vEwDjecGIYtf9ECZfcxi8V/_apis/pipelines/1/runs/21/artifacts?artifactName=github-pages","expiresOn":"2022-06-15T13:26:01.9505756Z","items":null}]}
Creating deployment with payload:
{
"artifact_url": "https://pipelines.actions.githubusercontent.com/odmqpuZ7yGar25NNWIM53v9pBjO9vEwDjecGIYtf9ECZfcxi8V/_apis/pipelines/1/runs/21/artifacts?artifactName=github-pages&%24expand=SignedContent",
"pages_build_version": "bf8f96d22c5dd116a5d94ee24cd398bdda60035f",
"oidc_token": "***"
}
Failed to create deployment for bf8f96d22c5dd116a5d94ee24cd398bdda60035f.
{"message":"Deployment request failed for bf8f96d22c5dd116a5d94ee24cd398bdda60035f due to in progress deployment. Please cancel e92de3f483b775a12d4f784d7cc661ff2847fa62 first or wait for it to complete.","documentation_url":"https://docs.github.com/rest/reference/repos#create-a-github-pages-deployment"}
Error: Error: Request failed with status code 400
Error: Error: Request failed with status code 400
Sending telemetry for run id 1998855719
Run Code Online (Sandbox Code Playgroud) 我目前正在使用lavaan 包进行R结构方程模型。我想计算每个路径系数的效应大小(即部分 eta 平方)。已经有一个包可以做到这一点吗?
例如,如何计算c、a和b回归系数的效应大小?
set.seed(1234)
X <- rnorm(100)
M <- 0.5*X + rnorm(100)
Y <- 0.7*M + rnorm(100)
Data <- data.frame(X = X, Y = Y, M = M)
model <- ' # direct effect
Y ~ c*X
# mediator
M ~ a*X
Y ~ b*M
# indirect effect (a*b)
ab := a*b
# total effect
total := c + (a*b)
'
fit <- sem(model, data = Data)
summary(fit) …Run Code Online (Sandbox Code Playgroud)